﻿var library = (function () {
    HTMLEnCode = function (str) {
        var s = "";
        if (str.length == 0) return "";
        s = str.replace(/&/g, "&gt;");
        s = s.replace(/</g, "&lt;");
        s = s.replace(/>/g, "&gt;");
        s = s.replace(/ /g, "&nbsp;");
        s = s.replace(/\'/g, "'");
        s = s.replace(/\"/g, "&quot;");
        s = s.replace(/\n/g, " <br>");
        return s;
    }
    HTMLDeCode = function (str) {
        var s = "";
        if (str.length == 0) return "";
        s = str.replace(/&gt;/g, "&");
        s = s.replace(/&lt;/g, "<");
        s = s.replace(/&gt;/g, ">");
        s = s.replace(/&nbsp;/g, " ");
        s = s.replace(/'/g, "\'");
        s = s.replace(/&quot;/g, "\"");
        s = s.replace(/ <br>/g, "\n");
        return s;
    }
    return {
        Common: (function () {
            return function () {
                this.Redirect = function (url) {
                    window.location.href = url;
                    if (jQuery.browser.version == '6.0') {
                        window.event.returnValue = false;
                    }
                };
            }
        })(),
        MissPwd: (function () {
            var rad = Math.random();
            var interval = null;
            var time = 120;
            ReflashTokenForMissPwd = function () {
                rad = Math.random();
                jQuery('input[name="token"]').val(rad);
            };
            setValidtorTimeOut = function () {
                if (interval == null) {
                    interval = window.setInterval(function () {
                        var s = parseInt(time, 10);
                        if (s > 0) {
                            time -= 1;
                        }
                        else {
                            jQuery('#ValidImg').trigger('click');
                        }
                    }, 1000);
                }
            }
            return function () {
                this.BindValidator = function () {
                    jQuery(function () {
                        ReflashTokenForMissPwd();
                        jQuery('#codeimg').html('<img  id="ValidImg" src="/account/validatetoken?t=' + rad + '" alt="点击刷新" onclick="Refalsh(this);" style="width:60px;height:25px;cursor:pointer;"/>');
                        setValidtorTimeOut();
                    });
                }
                this.Refalsh = function (sender) {
                    ReflashTokenForMissPwd();
                    time = 120;
                    jQuery('#Validator').val('');
                    jQuery(sender).attr('src', '/Account/ValidateToken?t=' + rad);

                };
            };
        })(),
        ReSend: (function () {
            var rad = Math.random();
            var interval = null;
            var time = 120;
            ReflashTokenForReSend = function () {
                rad = Math.random();
                jQuery('input[name="token"]').val(rad);
            };
            setValidtorTimeOut = function () {
                if (interval == null) {
                    interval = window.setInterval(function () {
                        var s = parseInt(time, 10);
                        if (s > 0) {
                            time -= 1;
                        }
                        else {
                            jQuery('#ValidImg').trigger('click');
                        }
                    }, 1000);
                }
            }
            return function () {
                this.BindValidator = function () {
                    jQuery(function () {
                        ReflashTokenForReSend();
                        jQuery('#codeimg').html('<img  id="ValidImg" src="/account/validatetoken?t=' + rad + '" alt="点击刷新" onclick="Refalsh(this);" style="width:60px;height:25px;cursor:pointer;"/>');
                        setValidtorTimeOut();
                    });
                }
                this.Refalsh = function (sender) {
                    ReflashTokenForReSend();
                    time = 120;
                    jQuery('#Validator').val('');
                    jQuery(sender).attr('src', '/Account/ValidateToken?t=' + rad);

                };
            };
        })(),
        Login: (function () {
            var rad = Math.random();
            var interval = null;
            var time = 120;
            ReflashTokenForLogin = function () {
                rad = Math.random();
                jQuery('input[name="token"]').val(rad);
            };
            setValidtorTimeOut = function () {
                if (interval == null) {
                    interval = window.setInterval(function () {
                        var s = parseInt(time, 10);
                        if (s > 0) {
                            time -= 1;
                        }
                        else {
                            jQuery('#ValidImg').trigger('click');
                        }
                    }, 1000);
                }
            }
            return function () {
                this.BindValidator = function () {
                    jQuery(function () {
                        ReflashTokenForLogin();
                        jQuery('#codeimg').html('<img  id="ValidImg" src="/account/validatetoken?t=' + rad + '" alt="点击刷新" onclick="Refalsh(this);" style="width:60px;height:25px;cursor:pointer;"/>');
                        setValidtorTimeOut();
                    });
                }
                this.Refalsh = function (sender) {
                    ReflashTokenForLogin();
                    time = 120;
                    jQuery('#Validator').val('');
                    jQuery(sender).attr('src', '/Account/ValidateToken?t=' + rad);

                };
            };
        })()
    }
})();
